package com.company.woye.console.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.company.woye.R;
import com.company.woye.console.entity.SingleDetailEntity;

import java.util.List;

//校验台listview
public class SingleDetailListviewAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context mContext;
    private List<SingleDetailEntity> entities;


    public SingleDetailListviewAdapter(Context context,List<SingleDetailEntity> entities) {
        this.inflater= LayoutInflater.from(context);
        this.mContext=context;
        this.entities=entities;
    }

    @Override
    public int getCount() {
        return entities.size();
    }

    @Override
    public Object getItem(int position) {
        return entities.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHodler viewHodler=null;
        if (convertView==null){
            convertView=inflater.inflate(R.layout.item_adapter_single_detail,parent,false);
            viewHodler=new ViewHodler(convertView);
            convertView.setTag(viewHodler);
        }else {
            viewHodler= (ViewHodler) convertView.getTag();
        }
        viewHodler.tv_01.setText(entities.get(position).getTxmQZ());
        viewHodler.tv_02.setText(entities.get(position).getTxmType());
        viewHodler.tv_03.setText(entities.get(position).getSumNumber());
        viewHodler.tv_04.setText(entities.get(position).getPackNum());
        viewHodler.tv_05.setText(entities.get(position).getScanPackNum());
        viewHodler.tv_06.setText(entities.get(position).getInNumber());
        viewHodler.tv_07.setText(entities.get(position).getInPackNumber());
        viewHodler.tv_08.setText(entities.get(position).getScanNumber());
        return convertView;
    }

    class ViewHodler{

        private TextView tv_01;
        private TextView tv_02;
        private TextView tv_03;
        private TextView tv_04;
        private TextView tv_05;
        private TextView tv_06;
        private TextView tv_07;
        private TextView tv_08;

        public ViewHodler(View view) {
            tv_01=view.findViewById(R.id.tv_01);
            tv_02=view.findViewById(R.id.tv_02);
            tv_03=view.findViewById(R.id.tv_03);
            tv_04=view.findViewById(R.id.tv_04);
            tv_05=view.findViewById(R.id.tv_05);
            tv_06=view.findViewById(R.id.tv_06);
            tv_07=view.findViewById(R.id.tv_07);
            tv_08=view.findViewById(R.id.tv_08);

        }
    }
}
